<script>
import zConfig from "@/uni_modules/z-paging/components/z-paging/js/z-paging-config";
// 导入创建用户信息Store的函数
import { globalStore } from "@/store";
import { useRoute } from "vue-router";
export default {
  onLaunch: async function () {
    console.log("App Launch");
    // 创建用户信息Store
    const gStore = globalStore();
    zConfig.setConfig({
      "empty-view-img": "/static/image/icon-nodata.png",
      "empty-view-error-img": "/static/image/nodata.png",
      "empty-view-fixed": false,
      "empty-view-style": { "margin-top": "-400rpx" },
      "empty-view-img-style": {
        width: "340rpx",
        height: "340rpx",
      },
    });
    const route = useRoute();
    const currentPath = route.path;
    let recNo = gStore.getUrlParam("recNo"); //获取recNo
    let code = gStore.getUrlParam("code");
    if (!gStore.token && !gStore.openid) {
      //获取当前页面的  开发环境用的
      // let link =
      //   "http://auth.cddzixun.com/wechat_accredit_callback.html?callback=" +
      //   encodeURIComponent(
      //     uni.$URL +
      //       "/pages/index/splash?recNo=" +
      //       recNo +
      //       "&callback=" +
      //       currentPath
      //   );
      // // 生产环境用;
      let link =
        uni.$URL +
        "/pages/index/splash?recNo=" +
        recNo +
        "&callback=" +
        currentPath;
      // 判断link中有没有code=字符串，
      if (!code) {
        //重定向地址，就是用户授权后返回来的地址
        let uri = encodeURIComponent(link);
        let authURL = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${uni.$appId}&redirect_uri=${uri}&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect`;
        window.location.href = authURL;
      }
    } else {
      await gStore.getToken(gStore.openid);
    }
  },
  onShow: function () {
    console.log("App Show");
  },
  onHide: function () {
    console.log("App Hide");
  },
};
</script>

<style lang="scss">
$u-border-color: #f3f3f3;
@import "@/uni_modules/uview-plus/index.scss";
.uni-video-ball {
  width: 16rpx !important;
  height: 16rpx !important;
  top: -34rpx !important;
}
.uni-video-bar {
  bottom: 50rpx !important;
  // bottom: calc(0 + constant(safe-area-inset-bottom)) !important;
  // bottom: calc(0rpx + env(safe-area-inset-bottom)) !important;
}
.uni-video-fullscreen {
  width: 12rpx !important;
  height: 12rpx !important;
}
.uni-video-control-button {
  width: 17rpx !important;
  height: 19rpx !important;
}
.uni-video-current-time,
.uni-video-duration {
  font-family: Arial, Helvetica, sans-serif;
}
.uni-video-controls {
  display: flex;
  align-items: center;
}
.zp-main-title {
  margin-top: -50rpx !important;
}
.u-form-item__body__left__content__required,
.u-form-item__body__left__content__label {
  font-size: 28rpx !important;
}
.u-form-item__body__left__content__label {
  color: #232f3f;
  margin-left: 20rpx;
}
.u-form-item__body__left__content__required {
  margin-left: 20rpx;
}
.button_t {
  font-size: 32rpx;
  color: #fff;
}
/*每个页面公共css */
</style>
